package com.unei.guava.demo.bujingnian;

import com.google.common.base.Function;
import com.google.common.base.Predicate;

/**
 * Created by sunlei on 2015/1/22.
 */
public class MsgRule {
    private Predicate<Msg> predicate;
    private Function<Msg,Msg> function;
    private boolean goon;

    public MsgRule(Predicate<Msg> predicate, Function<Msg, Msg> function, boolean goon) {
        this.predicate = predicate;
        this.function = function;
        this.goon = goon;
    }

    public boolean accept(Msg msg){
        return predicate.apply(msg);
    }

    public Msg process(Msg msg){
        return function.apply(msg);
    }

    public boolean goon(){
        return goon;
    }
}
